<?php
require_once 'source.php';
require_once 'config.php';
require_once 'dao/dao_db.php';
require_once 'dao/dao_teacher_manage.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
<div id="leftlay"><?php require_once 'leftnav.php';?></div>
<div id="rightlay">
<div class="columntitle">
	<?php if($_SESSION['level']==ADMINISTRATOR){
		echo CREATETEACHERACCOUNT;
	}else{
		echo CREATESTUDENTACCOUNT;
	}
	?>
</div>
<div class="columncontent" id="create_account">
<?php 
	if(isset($_GET['method'])&&$_GET['method']=='modify'){
		$method='modify';
	}else{
		$method='';
	}
?>

<form action="service/service_create_account.php?method=<?php echo $method?>" method="post">
	<div class="errormsg">
		<?php 
			if(isset($_GET['msg'])){
				if($_GET['msg']=='somethingisnull'){
					echo SOMETHINGISNULL;
				}elseif($_GET['msg']=='useridisnotanumeric'){
					echo USERIDISNOTANUMERIC;
				}elseif($_GET['msg']=='userexist'){
					echo USEREXIST;
				}elseif ($_GET['msg']=='createaccountsuccess'){
					echo CREATEACCOUNTSUCCESS;
				}
			}
		?>
	</div>
	<div>
	<?php 
		if(isset($_GET['userid'])&&$_SESSION['level']==ADMINISTRATOR){
			$result=get_teacher_account($_GET['userid']);
			$userid=$_GET['userid'];			 
			if(($row=mysql_fetch_array($result))!=FALSE){				
				$username=$row['USERNAME'];
				$gender=$row['GENDER'];
				$newsright=$row['NEWSRIGHT'];
			}
		}else{
			$userid='';
			$username='';
			$gender='';
			$newsright='';
		}
	?>
	<?php 
		if($_SESSION['level']==ADMINISTRATOR){
			echo TEACHERID;
		}elseif($_SESSION['level']==TEACHER){
			echo STUDENDTID;
		}
	?>:<input type="text" name="userid" value="<?php echo $userid?>" <?php if(isset($_GET['method'])&&$_GET['method']=='modify'){echo 'readonly';}?>/>
	</div>
	<div>
	
	<?php echo USERNAME?>:<input type="text" name="username" value="<?php echo $username?>"/>
	</div>
	<div>
	<?php echo GENTLEMAN?>
	<input type="radio" name="gender" value="<?php echo GENTLEMAN_NUM?>" 
	<?php
	 if(isset($gender)&&$gender==GENTLEMAN_NUM){
	 	 echo 'checked';}else{echo 'checked';}
	?>
	/>
	<?php echo LADY?>
	<input type="radio" name="gender" value="<?php echo LADY_NUM?>" <?php if(isset($gender)&&!$gender){ echo 'checked';}?>/>
	</div>
	<?php 
		if($_SESSION['level']==ADMINISTRATOR){
			if($newsright==NEWSRIGHT){
				$checked='checked';
			}else{
				$checked='';
			}
	?>
	<div>
		<input type="checkbox" name="newsright[]" <?php echo $checked?>/> <?php echo PUBLICNEWSRIGHT?>
	</div>
	<?php }?>
	<div>
	<input type="submit" value="<?php echo SUBMIT?>"/>
	</div>

</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>